/*
 * VentnaRenovarPrest.java
 *
 * Created on 21 de febrero de 2007, 03:27 PM
 */

package everest3.procesosBibliotecarios;

import everest3.Ayuda.MostrarAyuda;

import everest3.DateTextField; 
import java.awt.Dialog; 
import java.awt.Frame; 
import java.awt.event.ActionEvent; 
import java.awt.event.FocusEvent; 
import java.awt.event.MouseEvent; 
import javax.swing.JButton; 
import javax.swing.JDialog; 
import javax.swing.JFormattedTextField; 
import javax.swing.JLabel; 
import javax.swing.JPanel; 
import javax.swing.JSeparator; 
import javax.swing.JTextField;
import everest3.utils.Fecha;
import everest3.utils.ValidaFechas;
import java.sql.Time;
import java.text.ParseException;
import java.util.Date;
import java.util.Vector;
import javax.swing.text.MaskFormatter;

/**
 * Clase que administra la renovaci&oacute;n del pr&eacute;stamo de 
 * material Bibliogr&aacute;fico
 * @author JOSE LIBARDO MOLINA
 */
public class VentanaRenovarPrest extends javax.swing.JDialog {
    
    /**
     * Creates new form VentnaRenovarPrest
     * @param parent 
     * @param modal 
     */
    public VentanaRenovarPrest(java.awt.Frame parent, boolean modal) {
        super(parent, modal);
        initComponents();
    }
    /**
     * 
     * @param parent 
     * @param modal 
     * @param nombreUsuario 
     */
     public VentanaRenovarPrest(java.awt.Dialog parent, boolean modal, String nombreUsuario) {
        super(parent, modal);
        initComponents();
        jTUsuario.setText(nombreUsuario);
        
    }
    
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
    private void initComponents() {
        jPEncabezado = new javax.swing.JPanel();
        JTFecha = new javax.swing.JTextField();
        jTUsuario = new javax.swing.JTextField();
        jLlogo = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jLTitulo = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        jPanel1 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jTFechaDevl = new javax.swing.JTextField();
        jTHoraDevol = new javax.swing.JTextField();
        jLabel2 = new javax.swing.JLabel();
        jBConfirDevol = new javax.swing.JButton();
        jBCerrarDevol = new javax.swing.JButton();
        jPanel2 = new javax.swing.JPanel();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        MaskFormatter mf = null;

        try{
            mf = new MaskFormatter("##:##");//
        }catch(ParseException pe)
        {
            System.out.println("The mask does not contain valid mask characters");
        }
        jTHoraRenov = new javax.swing.JFormattedTextField(mf);
        jTFechaRenov = new everest3.DateTextField();
        jButton1 = new javax.swing.JButton();
        jSeparator1 = new javax.swing.JSeparator();
        jLEstado = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("Ventana Renovacion de prestamos");
        addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseEntered(java.awt.event.MouseEvent evt) {
                formMouseEntered(evt);
            }
        });

        jPEncabezado.setLayout(null);

        jPEncabezado.setBackground(new java.awt.Color(204, 204, 204));
        JTFecha.setEditable(false);
        JTFecha.setHorizontalAlignment(javax.swing.JTextField.RIGHT);
        JTFecha.setDisabledTextColor(new java.awt.Color(0, 0, 0));
        JTFecha.setDragEnabled(true);
        JTFecha.setEnabled(false);
        JTFecha.setFocusable(false);
        JTFecha.setText(FechaAct.obtenerFechaCompleta());
        jPEncabezado.add(JTFecha);
        JTFecha.setBounds(380, 10, 160, 20);

        jTUsuario.setEditable(false);
        jTUsuario.setHorizontalAlignment(javax.swing.JTextField.RIGHT);
        jTUsuario.setDisabledTextColor(new java.awt.Color(0, 0, 0));
        jTUsuario.setDragEnabled(true);
        jTUsuario.setEnabled(false);
        jPEncabezado.add(jTUsuario);
        jTUsuario.setBounds(380, 40, 160, 20);

        jLlogo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/everest3/imagenes/logo.JPG")));
        jLlogo.setVerticalAlignment(javax.swing.SwingConstants.BOTTOM);
        jLlogo.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jPEncabezado.add(jLlogo);
        jLlogo.setBounds(0, 0, 85, 64);

        jLabel6.setFont(new java.awt.Font("Tahoma", 1, 18));
        jLabel6.setText("Material Bibliogr\u00e1fico");
        jPEncabezado.add(jLabel6);
        jLabel6.setBounds(120, 40, 200, 22);

        jLabel5.setFont(new java.awt.Font("Tahoma", 1, 48));
        jLabel5.setText("R");
        jPEncabezado.add(jLabel5);
        jLabel5.setBounds(90, 0, 35, 40);

        jLTitulo.setFont(new java.awt.Font("Tahoma", 1, 18));
        jLTitulo.setText("enovaci\u00f3n de Pr\u00e9stamo");
        jPEncabezado.add(jLTitulo);
        jLTitulo.setBounds(125, 20, 220, 22);

        jLabel7.setIcon(new javax.swing.ImageIcon(getClass().getResource("/everest3/imagenes/Barra.jpg")));
        jPEncabezado.add(jLabel7);
        jLabel7.setBounds(0, 0, 560, 70);

        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("Fecha y hora de devoluci\u00f3n Vigente"));
        jLabel1.setText("Fecha (DD/MM/AA)");

        jTFechaDevl.setEditable(false);
        jTFechaDevl.setDisabledTextColor(new java.awt.Color(0, 0, 0));
        jTFechaDevl.setEnabled(false);
        jTFechaDevl.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseEntered(java.awt.event.MouseEvent evt) {
                jTFechaDevlMouseEntered(evt);
            }
        });

        jTHoraDevol.setEditable(false);
        jTHoraDevol.setDisabledTextColor(new java.awt.Color(0, 0, 0));
        jTHoraDevol.setEnabled(false);
        jTHoraDevol.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseEntered(java.awt.event.MouseEvent evt) {
                jTHoraDevolMouseEntered(evt);
            }
        });

        jLabel2.setText("Hora (HH:MM)");

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel1)
                    .addComponent(jLabel2))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jTHoraDevol, javax.swing.GroupLayout.PREFERRED_SIZE, 126, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jTFechaDevl, javax.swing.GroupLayout.PREFERRED_SIZE, 126, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jTFechaDevl, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel1))
                .addGap(16, 16, 16)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2)
                    .addComponent(jTHoraDevol, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(17, Short.MAX_VALUE))
        );

        jBConfirDevol.setText("Confirmar");
        jBConfirDevol.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseEntered(java.awt.event.MouseEvent evt) {
                jBConfirDevolMouseEntered(evt);
            }
        });
        jBConfirDevol.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBConfirDevolActionPerformed(evt);
            }
        });
        jBConfirDevol.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusGained(java.awt.event.FocusEvent evt) {
                jBConfirDevolFocusGained(evt);
            }
        });

        jBCerrarDevol.setText("Cerrar");
        jBCerrarDevol.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseEntered(java.awt.event.MouseEvent evt) {
                jBCerrarDevolMouseEntered(evt);
            }
        });
        jBCerrarDevol.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBCerrarDevolActionPerformed(evt);
            }
        });
        jBCerrarDevol.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusGained(java.awt.event.FocusEvent evt) {
                jBCerrarDevolFocusGained(evt);
            }
        });

        jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder("Fecha y hora de Renovaci\u00f3n de la Devoluci\u00f3n"));
        jLabel3.setText("Fecha (DD/MM/AA)");

        jLabel4.setText("Hora (HH:MM)");

        jTHoraRenov.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseEntered(java.awt.event.MouseEvent evt) {
                jTHoraRenovMouseEntered(evt);
            }
        });
        jTHoraRenov.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTHoraRenovActionPerformed(evt);
            }
        });

        jTFechaRenov.setEditable(false);
        jTFechaRenov.setText("");
        jTFechaRenov.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jTFechaRenovMouseClicked(evt);
            }
            public void mouseEntered(java.awt.event.MouseEvent evt) {
                jTFechaRenovMouseEntered(evt);
            }
        });

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel3)
                    .addComponent(jLabel4))
                .addGap(15, 15, 15)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jTHoraRenov, javax.swing.GroupLayout.DEFAULT_SIZE, 115, Short.MAX_VALUE)
                    .addComponent(jTFechaRenov, javax.swing.GroupLayout.DEFAULT_SIZE, 115, Short.MAX_VALUE))
                .addContainerGap())
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel3)
                    .addComponent(jTFechaRenov, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 11, Short.MAX_VALUE)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel4)
                    .addComponent(jTHoraRenov, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );

        jButton1.setText("Ayuda");
        jButton1.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseEntered(java.awt.event.MouseEvent evt) {
                jButton1MouseEntered(evt);
            }
        });
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });
        jButton1.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusGained(java.awt.event.FocusEvent evt) {
                jButton1FocusGained(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 15, Short.MAX_VALUE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jBConfirDevol)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jBCerrarDevol)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jButton1)))
                .addContainerGap())
            .addComponent(jPEncabezado, javax.swing.GroupLayout.DEFAULT_SIZE, 551, Short.MAX_VALUE)
            .addComponent(jSeparator1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 551, Short.MAX_VALUE)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLEstado, javax.swing.GroupLayout.PREFERRED_SIZE, 435, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(106, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jPEncabezado, javax.swing.GroupLayout.PREFERRED_SIZE, 64, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                    .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButton1)
                    .addComponent(jBCerrarDevol)
                    .addComponent(jBConfirDevol))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, 2, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLEstado, javax.swing.GroupLayout.DEFAULT_SIZE, 19, Short.MAX_VALUE))
        );
        java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
        setBounds((screenSize.width-559)/2, (screenSize.height-281)/2, 559, 281);
    }// </editor-fold>//GEN-END:initComponents

    private void formMouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_formMouseEntered
// TODO add your handling code here:
        barraEstado("");
    }//GEN-LAST:event_formMouseEntered

    private void jTFechaRenovMouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jTFechaRenovMouseEntered
// TODO add your handling code here:
        barraEstado("Elige la Fecha de Devoluci\u00f3n Nuevamente Acordada");
    }//GEN-LAST:event_jTFechaRenovMouseEntered

    private void jTHoraRenovMouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jTHoraRenovMouseEntered
// TODO add your handling code here:
        barraEstado("Digita la Hora de Devoluci\u00f3n Nuevamente Acordada");
    }//GEN-LAST:event_jTHoraRenovMouseEntered

    private void jTHoraDevolMouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jTHoraDevolMouseEntered
// TODO add your handling code here:
        barraEstado("Visualiza la Hora de Devoluci\u00f3n Previamente Acordada");
    }//GEN-LAST:event_jTHoraDevolMouseEntered

    private void jTFechaDevlMouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jTFechaDevlMouseEntered
// TODO add your handling code here:
        barraEstado("Visualiza la Fecha de Devoluci\u00f3n Previamente Acordada");
    }//GEN-LAST:event_jTFechaDevlMouseEntered

    private void jButton1MouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButton1MouseEntered
// TODO add your handling code here:
        barraEstado("Visualiza la Ayuda del Sistema");
    }//GEN-LAST:event_jButton1MouseEntered

    private void jButton1FocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jButton1FocusGained
// TODO add your handling code here:
        barraEstado("Visualiza la Ayuda del Sistema");
    }//GEN-LAST:event_jButton1FocusGained

    private void jBCerrarDevolMouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jBCerrarDevolMouseEntered
// TODO add your handling code here:
        barraEstado("Cierra esta Ventana y Vuelve al Menu Principal de Administraci\u00f3n");
    }//GEN-LAST:event_jBCerrarDevolMouseEntered

    private void jBCerrarDevolFocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jBCerrarDevolFocusGained
// TODO add your handling code here:
        barraEstado("Cierra esta Ventana y Vuelve al Menu Principal de Administraci\u00f3n");
    }//GEN-LAST:event_jBCerrarDevolFocusGained

    private void jBConfirDevolFocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jBConfirDevolFocusGained
// TODO add your handling code here:
       barraEstado("Guarda la Renovaci\u00f3n del Material Bibliogr\u00e1fico del Sistema"); 
    }//GEN-LAST:event_jBConfirDevolFocusGained

    private void jBConfirDevolMouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jBConfirDevolMouseEntered
// TODO add your handling code here:
       barraEstado("Guarda la Renovaci\u00f3n del Material Bibliogr\u00e1fico del Sistema");
    }//GEN-LAST:event_jBConfirDevolMouseEntered

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
// TODO add your handling code here:
        new MostrarAyuda();
    }//GEN-LAST:event_jButton1ActionPerformed

    private void jBConfirDevolActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBConfirDevolActionPerformed
// TODO add your handling code here:
       ingresarRenovacion();
    }//GEN-LAST:event_jBConfirDevolActionPerformed

    private void jTFechaRenovMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jTFechaRenovMouseClicked
// TODO add your handling code here:
        Date newDate = jTFechaRenov.DATE_CHOOSER.select(jTFechaRenov.date);
        if ( newDate == null )
            return;
        jTFechaRenov.setDate( newDate );
    }//GEN-LAST:event_jTFechaRenovMouseClicked

    private void jTHoraRenovActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTHoraRenovActionPerformed
        Fecha fecha;
// TODO add your handling code here:
        fecha= new Fecha();
        
        if (jTHoraRenov.isEditValid()){
            if (fecha.validarHora(jTHoraRenov.getText())){
                //jTHoraDevl.setVerifyInputWhenFocusTarget(true);
                jTHoraRenov.setVerifyInputWhenFocusTarget(true);
                jTHoraRenov.setValue(fecha.verHoraTotal());               
                
            }
            else
                 ingresarRenovacion();
            
            
        } else
            javax.swing.JOptionPane.showMessageDialog(this,"dd/MM/aaaa","fecha erronea",javax.swing.JOptionPane.ERROR_MESSAGE);
    }//GEN-LAST:event_jTHoraRenovActionPerformed

    private void jBCerrarDevolActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBCerrarDevolActionPerformed
// TODO add your handling code here:
         this.setVisible(false);
    }//GEN-LAST:event_jBCerrarDevolActionPerformed
    
    /**
     * Metodo que se encarga de actualizar la fecha de devoluci&oacute;n 
     * del pr&eacute;stamo activo
     */
    public void ingresarRenovacion(){
          if(jTFechaRenov.getText().equals("")||(jTHoraRenov.getText().equals("")))
            javax.swing.JOptionPane.showMessageDialog(this,"Uno de los campos se encuentra vacio","Error Datos invalidos",javax.swing.JOptionPane.ERROR_MESSAGE);
         else{
             Fecha fecha = new Fecha();
            
             if (fecha.validarHora(jTHoraRenov.getText())){
                 jTHoraRenov.setVerifyInputWhenFocusTarget(true);
                 jTHoraRenov.setValue(fecha.verHoraTotal());
                 
             }
             else 
             {
                 validarRenovacion();//llama al metodo de validar la renovacion
             }                  
                
            }
    }
 /**
     * metodo que me permite obtener los valores del material bibliogr&aacute;fico que se desea devolver
     * @param datos Objeto de la clase <CODE>java.util.Vector</CODE> que contiene la informaci&oacute;n
     * del material bibliogr&aacute;fico a devolver y del cliente asociado a dicho prestamo
     */
    public void datosPrestamo(Vector datos){
        this.datos=datos;   
        hora();
        cargarHoraAcordada();
    }    
    private void cargarHoraAcordada()
    {
        jTFechaDevl.setText(FechaAct.cambioFormatoFecha2(datos.elementAt(5).toString()));
        jTHoraDevol.setText(datos.elementAt(6).toString());
        jTHoraRenov.setText(datos.elementAt(6).toString());
        
    }
       /**
     * Carga la hora de entrega del material bbiliografico
     * 
     */
    private void hora(){
     tablasYBasesdeDatos.JDBCAdapter dataBase = new tablasYBasesdeDatos.JDBCAdapter(
            "jdbc:postgresql://localhost:5432/everest",
            "org.postgresql.Driver",
            "postgres",
            "root");
     //***** Posible Error en concordancia de datos *****
    Vector valores=dataBase.ConsultaIndividual("select basehoraentrega, basehoraacordada from prestamoact where  basefechaentrega='"+datos.elementAt(0)+"' and cliid="+datos.elementAt(7)+" and areacodigo ="+datos.elementAt(2) +"and matcons="+datos.elementAt(3));
//    System.out.println(valores.elementAt(0));
    datos.setElementAt(valores.elementAt(0),1);
    datos.setElementAt(valores.elementAt(1),6);
    
}
    /**
     * este metodo me pertmite validar la devolucion del material bibliografico prestado, 
     * en donde se evalua la fecha y hora de devolucion acordada con la fecha y hora de devolucion
     * real (previamente capturada), y posteriormente estableciendo la pauta para la generacion
     * o no de multa por retraso en la entrega de dicho material bibliografico
     */
public void validarRenovacion(){
       java.sql.Date fechaAcSQL = new java.sql.Date(new java.util.Date().getTime());
       Time horaAcSQL = new Time(new java.util.Date().getTime());
     ValidaFechas obj = new ValidaFechas(FechaAct.cambioFormatoFecha(jTFechaRenov.getText()),//fecha renovacion
                         jTHoraRenov.getText(),//hora renovacion
                         fechaAcSQL.toString(),//fecha actual
                        horaAcSQL.toString());//hora actual
     
    if(obj.getTiempoTranscurrido(5)>0){
          ValidaFechas obj2 = new ValidaFechas(fechaAcSQL.toString(),//fecha actual 
                     horaAcSQL.toString(),//hora actual
                     datos.elementAt(5).toString().trim(),//fecha acordada
                     ""+datos.elementAt(6));//hora acordada  		
            datos.add(9,FechaAct.cambioFormatoFecha(jTFechaRenov.getText()));
            datos.add(10,jTHoraRenov.getText());
            if((obj2.getTiempoTranscurrido(5)>0)&&(javax.swing.JOptionPane.showConfirmDialog(this,"La fecha de devoluci\u00f3n previamente acordada "
                       +" es menor a la fecha y hora actual.\n\u00bfDesea realmente realizar la respectiva renovaci\u00f3n del pr\u00e9stamo?\nPresione Si para efecutar la renovaci\u00f3n  ",
                       "Error el pr\u00e9stamo no se puede renovar",javax.swing.JOptionPane.YES_NO_OPTION,javax.swing.JOptionPane.WARNING_MESSAGE)!=0))
            {               
                dispose();                                                            

           }
            else
            {
                datos.setElementAt(FechaAct.cambioFormatoFecha(jTFechaRenov.getText()),5);
                datos.setElementAt(jTHoraRenov.getText(),6);
                 NuevoPrestamo  actualizaPrestamo = new NuevoPrestamo();  
                 actualizaPrestamo.guardarRenuevaPrestamo(datos);
                 dispose();

            }
          }
    else
        javax.swing.JOptionPane.showMessageDialog(this,"La Fecha de renovacion es menor a la fecha actual","Error fecha invalida",javax.swing.JOptionPane.ERROR_MESSAGE);
        
       }
private void barraEstado(String mensaje)
      {
          jLEstado.setText(mensaje);
      }
 
    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new VentanaRenovarPrest(new javax.swing.JFrame(), true).setVisible(true);
            }
        });
    }
     Fecha FechaAct = new Fecha();
    private Vector datos;
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JTextField JTFecha;
    private javax.swing.JButton jBCerrarDevol;
    private javax.swing.JButton jBConfirDevol;
    private javax.swing.JButton jButton1;
    private javax.swing.JLabel jLEstado;
    private javax.swing.JLabel jLTitulo;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLlogo;
    private javax.swing.JPanel jPEncabezado;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JSeparator jSeparator1;
    private javax.swing.JTextField jTFechaDevl;
    private everest3.DateTextField jTFechaRenov;
    private javax.swing.JTextField jTHoraDevol;
    private javax.swing.JFormattedTextField jTHoraRenov;
    private javax.swing.JTextField jTUsuario;
    // End of variables declaration//GEN-END:variables
    
}
